package _工具包整理._判断对象相等;

import org.junit.Test;

import java.util.Objects;

public class ObjectsEqualsTest {

    @Test
    public void test001() {
        // 1.7 Objects.equals()
        Integer a001 = null;
        Integer a002 = null;
        System.out.println(Objects.equals(a001, a002));// 用 ==

        Integer a003 = 2;
        Integer a004 = null;
        System.out.println(Objects.equals(a003, a004));// 用 ==

        Integer a005 = 2;
        Integer a006 = 2;
        System.out.println(Objects.equals(a005, a006));// 用 equals

        int a007 = 2;
        Integer a008 = 2;
        System.out.println(Objects.equals(a007, a008));// equals 自动装箱，变为 Integer.equals(Integer)
        Long a009 = 2L;
        System.out.println(Objects.equals(a007, a009));// equals 自动装箱，变为 Integer.equals(Long)
        System.out.println(Objects.equals(a008, a009));// Integer.equals(Long) 不报错，返回 false
    }

}
